package service;

import java.util.*;

/**
 * @author oldliu
 * @since 1.0
 */
public class UserService {
    static List<User> users = new ArrayList<>();
    static {
        users.add(new User(1, "老吴", "124"));
        users.add(new User(2, "老张", "124"));
        users.add(new User(3, "小赵", "124"));
        users.add(new User(4, "Tony", "124"));
    }

    public int add(User user) {
        users.add(user);
        return 1;
    }
    public int add(int id,String n,String p) {
        users.add(new User(id,n,p));
        return 1;
    }
    public int del(int id) {
        for (User u : users) {
            if (u.getId() == id) {
                users.remove(u);
                return 1;
            }
        }
        return 0;
    }

    public List<User> search() {
        return users;
    }
}
